package org.nashua.tt151.systems;

import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.templates.Dash;
import java.io.IOException;
import org.nashua.tt151.libraries.Controller.DualAction;

/**
 * 2014 Camera Control System
 * Handles control of the camera angling servo and the LED ring
 *
 * @author Kareem El-Faramawi
 */
public class Camera extends Subsystem {
	private static Camera INSTANCE;
	private static final Relay LED = new Relay( 1, Relay.Direction.kForward );

	private Camera() {
	}

	public static Camera getInstance() {
		if ( INSTANCE == null ) {
			INSTANCE = new Camera();
		}
		return INSTANCE;
	}

	public void init() {
		LED.set( Relay.Value.kOn ); //Turn on the LED
	}

	public void updateDashboard( Dash dash ) throws IOException {
		dash.sendRelay( LED.get(), "LED", 1, Relay.Direction.kForward );
	}

	public void operatorControl( DualAction driver, DualAction shooter ) {
		//Maps the start button to toggling the LED
		if ( shooter.wasReleased( DualAction.Button.START ) ) {
			LED.set( LED.get() == Relay.Value.kOff ? Relay.Value.kOn : Relay.Value.kOff );
		}
	}
}
